#!/bin/bash

#nginx
nginx_name=nginx-1.13.5 #nginx版本
#安装必要软件
yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

wget -c https://nginx.org/download/${nginx_name}.tar.gz

tar -zxvf ${nginx_name}.tar.gz

cd ${nginx_name}

if [ ! -f /opt/nginx ];then
        mkdir -p /opt/nginx
fi

#./configure 
./configure \
--prefix=/opt/nginx

make && make install

#启动nginx
cd /opt/nginx/sbin/
./nginx
cd
#开机自启动
echo "/opt/nginx/sbin/nginx" >> /etc/rc.local
chmod 755 /etc/rc.local

